{extend name="base"/}
{block name="resources"}
{/block}
{block name="main"}
<div class="layui-collapse ns-tips">
	<div class="layui-colla-item">
		<h2 class="layui-colla-title">操作提示</h2>
		<ul class="layui-colla-content layui-show">
			<li>当前页面针对续签申请进行管理，可以针对续签申请审核支付操作。</li>
			<li>续签流程：会员续签申请上传支付凭据->审核支付信息->审核通过延续入驻时间。</li>
		</ul>
	</div>
</div>

<div class="ns-screen layui-collapse" lay-filter="selection_panel">
	<div class="layui-colla-item">
		<h2 class="layui-colla-title">筛选</h2>
		<form class="layui-colla-content layui-form layui-show">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">主营行业</label>
					<div class="layui-input-inline">
						<select name="category_id" lay-filter="status">
							<option value="">全部</option>
							{foreach $shop_category_list as $list_k => $list_v}
							<option value="{$list_v.category_id}">{$list_v.category_name}</option>
							{/foreach}
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">开店套餐</label>
					<div class="layui-input-inline">
						<select name="group_id" lay-filter="status">
							<option value="">全部</option>
							{foreach $shop_group_list as $list_k => $list_v}
							<option value="{$list_v.group_id}">{$list_v.group_name}</option>
							{/foreach}
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">申请状态</label>
					<div class="layui-input-inline">
						<select name="apply_state" lay-filter="status">
							<option value="">全部</option>
							<option value="1">待审核</option>
							<option value="2">审核成功</option>
						</select>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">店铺名称</label>
					<div class="layui-input-inline ns-len-mid">
						<input type="text" id="search_text" name="site_name" placeholder="店铺名称" autocomplete="off" class="layui-input">
					</div>
				</div>
			</div>
			<div class="ns-form-row">
				<button class="layui-btn ns-bg-color" lay-submit lay-filter="search">筛选</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</form>
	</div>
</div>
<div class="layui-tab ns-table-tab" lay-filter="reopen_list_tab">
	<ul class="layui-tab-title">
		<li class="layui-this" data-status="">全部</li>
		<li data-status="1" data-type="apply_state">待审核</li>
		<li data-status="2" data-type="apply_state">审核通过</li>
		<li data-status="-1" data-type="apply_state">审核拒绝</li>

	</ul>
	<div class="layui-tab-content">
		<!-- 列表 -->
		<table id="renewal_list" lay-filter="renewal_list"></table>
	</div>
</div>


<!-- 付款凭证 -->
<script type="text/html" id="paymentVoucher">
	<div class="ns-img-box">
		{{#  if(d.paying_money_certificate){  }}
		<img onclick="showImg('{{ ns.img(d.paying_money_certificate) }}')" src="{{ns.img(d.paying_money_certificate)}}"/>
		{{#  }  }}
	</div>
</script>

<!-- 状态 -->
<script type="text/html" id="status">
	{{#  if(d.apply_state == 1){  }}
	待审核
	{{#  }else if(d.apply_state == -1){  }}
	审核拒绝
	{{#  }else if(d.apply_state == 2){  }}
	审核成功
	{{#  }  }}
</script>

<!-- 工具栏操作 -->
<script type="text/html" id="operation">
	<div class="ns-table-btn">
		<a class="layui-btn" lay-event="detail">申请详情</a>
	</div>
</script>
{/block}
{block name="script"}
<script>
	layui.use(['form', 'element'], function() {
		var table,
			form = layui.form,
            element = layui.element,
			repeat_flag = false;
		form.render();


        //监听Tab切换，以改变地址hash值
        element.on('tab(reopen_list_tab)', function () {
            table.reload({
                page: {
                    curr: 1
                },
                where: {
                    'apply_state': this.getAttribute('data-status')
                }
            });
        });

		/**
		 * 加载表格
		 */
		table = new Table({
			elem: '#renewal_list',
			url: ns.url("city://city/shopreopen/reopen"),
			cols: [
				[{
                    field: 'reopen_no',
                    title: '账单编号',
                    unresize: 'false'
                },{
					field: 'site_name',
					title: '店铺名称',
					unresize: 'false'
				}, {
					field: 'shop_group_name',
					title: '续签等级',
					unresize: 'false'
				}, {
					field: 'apply_year',
					title: '续签时长（年）',
					unresize: 'false',
					width: '10%'
				}, {
					field: 'paying_amount',
					title: '<span style="padding-right: 15px;">续签费用</span>',
					unresize: 'false',
					align: 'right',
					width: '12%',
					templet: function(data) {
						return '<span style="padding-right: 15px;">￥'+ data.paying_amount +'</span>';
					}
				}, {
					title: '状态',
					unresize: 'false',
					templet: '#status'
				}, {
					field: 'create_time',
					title: '创建时间',
					unresize: 'false',
					templet: function(data) {
						return ns.time_to_date(data.create_time)
					}
				}, {
					title: '操作',
					width: '10%',
					unresize: 'false',
					toolbar: '#operation'
				}]
			]
		});
		
		/**
		 * 监听工具栏操作
		 */
		table.tool(function(obj) {
			var data = obj.data;
			console.log(data);
			switch (obj.event) {
				case 'detail': //详情
					location.href = ns.url("city://city/shopreopen/reopendetail?id="+ data.id);
					break;
			}
		});

		
		/**
		 * 搜索功能
		 */
		form.on('submit(search)', function(data) {
			table.reload({
				page: {
					curr: 1
				},
				where: data.field
			});
			return false;
		});
	})

	function showImg(img) {
		layer.open({
			type: 21,
			title: false,
			closeBtn: 0,
			skin: 'layui-layer-nobg', //没有背景色
			shadeClose: true,
			content: '<img src="'+img+'">'
		});
	}
</script>
{/block}